package com.atung.dao;


import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.atung.model.AdmSchool;
import com.atung.provider.AdmSchoolProvider;

@Mapper
public interface AdmSchoolDAO {

	/**
	 * 根据学校id查询学校
	 * @param id
	 * @return
	 */
	@Select("select * from adm_school where id=#{id} and is_delect=0 and is_employ=0 ")
	AdmSchool selectAdmSchoolById(@Param("id") Long id);
	
	/**
	 * 切换学校
	 * @param schoolName
	 * @return
	 */
	@SelectProvider(type=AdmSchoolProvider.class,method="selectSchoolNameLikeAllProvider")
	List<AdmSchool>selectSchoolNameLikeAll(@Param("schoolName")String schoolName);

	/**
	 * 推荐附近十所学校
	 * @param lon
	 * @param lat
	 * @return
	 */
	@Select(" select * from adm_school where "
			+ " sqrt( ( ((#{lon}-lon)*PI()*12656*cos(((#{lat}+lat)/2)*PI()/180)/180) * "
			+ " ((#{lon}-lon)*PI()*12656*cos (((#{lat}+lat)/2)*PI()/180)/180) ) + "
			+ " ( ((#{lat}-lat)*PI()*12656/180) * ((#{lat}-lat)*PI()*12656/180) ) )<#{scope} limit 10")
	List<AdmSchool> selectSchoolBylonAndlat(@Param("lon")String lon, @Param("lat")String lat,@Param("scope") Integer scope);
}
